using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;

namespace Zoo.DAL
{
	/// <summary>
	/// Strongly-typed collection for the Dictionary class.
	/// </summary>
	[Serializable]
	public partial class DictionaryCollection : ActiveList<Dictionary, DictionaryCollection> 
	{	   
		public DictionaryCollection() {}

	}

	/// <summary>
	/// This is an ActiveRecord class which wraps the Dictionary table.
	/// </summary>
	[Serializable]
	public partial class Dictionary : ActiveRecord<Dictionary>
	{
		#region .ctors and Default Settings
		
		public Dictionary()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}

		
		private void InitSetDefaults() { SetDefaults(); }

		
		public Dictionary(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}

		public Dictionary(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}

		 
		public Dictionary(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}

		
		protected static void SetSQLProps() { GetTableSchema(); }

		
		#endregion
		
		#region Schema and Query Accessor
		public static Query CreateQuery() { return new Query(Schema); }

		
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}

		}

		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("Dictionary", TableType.Table, DataService.GetInstance("ZooDB"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"dbo";
				//columns
				
				TableSchema.TableColumn colvarDictionaryKey = new TableSchema.TableColumn(schema);
				colvarDictionaryKey.ColumnName = "DictionaryKey";
				colvarDictionaryKey.DataType = DbType.String;
				colvarDictionaryKey.MaxLength = 50;
				colvarDictionaryKey.AutoIncrement = false;
				colvarDictionaryKey.IsNullable = false;
				colvarDictionaryKey.IsPrimaryKey = true;
				colvarDictionaryKey.IsForeignKey = false;
				colvarDictionaryKey.IsReadOnly = false;
				colvarDictionaryKey.DefaultSetting = @"";
				colvarDictionaryKey.ForeignKeyTableName = "";
				schema.Columns.Add(colvarDictionaryKey);
				
				TableSchema.TableColumn colvarFr = new TableSchema.TableColumn(schema);
				colvarFr.ColumnName = "fr";
				colvarFr.DataType = DbType.String;
				colvarFr.MaxLength = 2147483647;
				colvarFr.AutoIncrement = false;
				colvarFr.IsNullable = true;
				colvarFr.IsPrimaryKey = false;
				colvarFr.IsForeignKey = false;
				colvarFr.IsReadOnly = false;
				colvarFr.DefaultSetting = @"";
				colvarFr.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFr);
				
				TableSchema.TableColumn colvarNl = new TableSchema.TableColumn(schema);
				colvarNl.ColumnName = "nl";
				colvarNl.DataType = DbType.String;
				colvarNl.MaxLength = 2147483647;
				colvarNl.AutoIncrement = false;
				colvarNl.IsNullable = true;
				colvarNl.IsPrimaryKey = false;
				colvarNl.IsForeignKey = false;
				colvarNl.IsReadOnly = false;
				colvarNl.DefaultSetting = @"";
				colvarNl.ForeignKeyTableName = "";
				schema.Columns.Add(colvarNl);
				
				TableSchema.TableColumn colvarEn = new TableSchema.TableColumn(schema);
				colvarEn.ColumnName = "en";
				colvarEn.DataType = DbType.String;
				colvarEn.MaxLength = 2147483647;
				colvarEn.AutoIncrement = false;
				colvarEn.IsNullable = true;
				colvarEn.IsPrimaryKey = false;
				colvarEn.IsForeignKey = false;
				colvarEn.IsReadOnly = false;
				colvarEn.DefaultSetting = @"";
				colvarEn.ForeignKeyTableName = "";
				schema.Columns.Add(colvarEn);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["ZooDB"].AddSchema("Dictionary",schema);
			}

		}

		#endregion
		
		#region Props
		
		  
		[XmlAttribute("DictionaryKey")]
		public string DictionaryKey 
		{
			get { return GetColumnValue<string>("DictionaryKey"); }

			set { SetColumnValue("DictionaryKey", value); }

		}

		  
		[XmlAttribute("Fr")]
		public string Fr 
		{
			get { return GetColumnValue<string>("fr"); }

			set { SetColumnValue("fr", value); }

		}

		  
		[XmlAttribute("Nl")]
		public string Nl 
		{
			get { return GetColumnValue<string>("nl"); }

			set { SetColumnValue("nl", value); }

		}

		  
		[XmlAttribute("En")]
		public string En 
		{
			get { return GetColumnValue<string>("en"); }

			set { SetColumnValue("en", value); }

		}

		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(string varDictionaryKey,string varFr,string varNl,string varEn)
		{
			Dictionary item = new Dictionary();
			
			item.DictionaryKey = varDictionaryKey;
			
			item.Fr = varFr;
			
			item.Nl = varNl;
			
			item.En = varEn;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(string varDictionaryKey,string varFr,string varNl,string varEn)
		{
			Dictionary item = new Dictionary();
			
				item.DictionaryKey = varDictionaryKey;
				
				item.Fr = varFr;
				
				item.Nl = varNl;
				
				item.En = varEn;
				
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}

		#endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string DictionaryKey = @"DictionaryKey";
			 public static string Fr = @"fr";
			 public static string Nl = @"nl";
			 public static string En = @"en";
						
		}

		#endregion
	}

}

